﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Web.UI.DataVisualization.Charting;

namespace HZ.Supervise.Web.Secondphase.ShowImage.test
{
    public partial class MsChart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                ShowChart();
            }
        }

        /// <summary>
        /// 选择显示方式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {

        }

        protected void ShowChart()
        {
            //取得数据
            DataTable dt = new DataTable();
            DataColumn dc0 = new DataColumn("X", typeof(string)); dt.Columns.Add(dc0);
            DataColumn dc1 = new DataColumn("Y", typeof(string)); dt.Columns.Add(dc1);
            for (int i = 1; i < 13; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = (i*100).ToString();
                dr[1] = (i * 200).ToString();
                dt.Rows.Add(dr);
            }
            dt.AcceptChanges();

            //整理数据
            int[] X = new int[dt.Rows.Count];
            int[] Y = new int[dt.Rows.Count];
            
            for(int i=0;i<dt.Rows.Count;i++)
            {
                X[i] = int.Parse(dt.Rows[i]["X"].ToString());
                Y[i] = int.Parse(dt.Rows[i]["Y"].ToString());
            }

            //赋值给控件
            Chart1.Series["Series1"].Points.DataBindXY(X, Y);
            Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;

            Chart1.Series["Series1"]["PieLableStyle"] = "OutSide";
            Chart1.Series["Series1"]["DoughnutRadios"] = "99";
            Chart1.Series["Series1"].IsValueShownAsLabel = true;
            Chart1.Series["Series1"]["BarLableStyle"] = "Center";
            Chart1.Series["Series1"]["PointWidth"] = "0.5";
        }
    }
}
